<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>promise</title>
    <style>
        p{
            font-size: 20px;
            color: #000;
            margin: 10px 0;
            line-height: 2;
        }
        button{
            display: inline-block;
            min-width: 100px;
            height: 40px;
            border-radius: 10px;
            font-size: 18px;
            text-align: center;
            line-height: 40px;
        }
        pre{
            font-size: 18px;
        }
    </style>
</head>
<body>
    <button onclick='promiseType(1)'>Promise的状态-完成</button>
    <button onclick='promiseType(0)'>Promise的状态-拒绝</button>




</p>
    <p></p>
</body>
<script>
    function promiseType(type){
        return new Promise(function(resolve, reject) {
            if(type) { 
                resolve('已经完成') 
            }else{
                reject('拒绝执行')
            }
        }).then(function(e){
            console.log(e)
        },function(e){
            console.error(e)
        })
    }
    function promiseType1(type){
        return new Promise(function(resolve, reject) {
            if(type) { 
                resolve('已经完成') 
            }else{
                reject('拒绝执行')
            }
        }).then(function(e){
            console.log(e)
        }).catch(function(e){
            console.error(e)
        })
    }
    function promiseType2(type){
        return new Promise(function(resolve, reject) {
            if(type) { 
                resolve('已经完成') 
            }else{
                reject('拒绝执行')
            }
        }).then(function(e){
            console.log(e)
        }).then(null,function(e){
            console.error(e)
        })
    }
// 转载链接：https://www.jianshu.com/p/fe5f173276bd
</script>
</html>